package com.ux.example.mathmatic
{
	import com.ux.manager.StageManager;
	
	import flash.display.Shape;
	import flash.display.MovieClip;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;

	
	public class MakeCircleUsingAtan extends Sprite
	{
		
		private var mc : MovieClip;
		private var angle : Number       = 0;
		private var theta : Number       = 0;
		private var speed : Number       = 1;
		private var radius : Number      = 50;
		private var cx : Number          = 200;
		private var cy : Number          = 200;

		
		public function MakeCircleUsingAtan()
		{
			super();
			
			this.mc                    = new MovieClip();
			var ball : Shape           = new Shape();
			
			ball.graphics.beginFill( 0x000000, 1 );
			ball.graphics.drawCircle( 0,0, 1 );
			ball.graphics.endFill();
			
			this.mc.addChild( ball );
			this.addChild( mc );
			
			this.addEventListener( Event.ENTER_FRAME, onEnter );


		}
		
		
		private function onEnter( e:Event ):void
		{
			
			this.angle          += this.speed;
			this.theta          = this.angle*2*Math.PI/360;
			
			this.mc.x           = this.radius * Math.cos( this.theta ) + this.cx; 
			this.mc.y           = this.radius * Math.sin( this.theta ) + this.cy;
			
			trace(" ==> MakeCircleUsingAtan onEnter : " + angle );
			
			if( angle == 360 )
			{
				this.removeEventListener( Event.ENTER_FRAME, onEnter );
			}

		}
	}
}